# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Michal Zalewski <lcamtuf[at]coredump[dot]cx>
# Contributor: cbreaker <cbreaker[at]tlen[dot]pl>]
# Contributor: Tino Reichardt
# Contributor: Timothée Ravier <tim[at]siosm[dot]fr>

pkgname=p0f
pkgver=3.09b
pkgrel=3
pkgdesc="Purely passive TCP/IP traffic fingerprinting tool"
url="http://lcamtuf.coredump.cx/p0f3/"
arch=('loong64' 'x86_64')
license=('GPL2')
depends=('libpcap')
backup=('etc/p0f/p0f.fp')
source=(http://lcamtuf.coredump.cx/p0f3/releases/${pkgname}-${pkgver}.tgz)
sha512sums=('2a688baa865f27c91c023a7c53e530649f56a681e6ca2533152ab07b42883857b20c378b636e87dda8d1d5dfac17e426d09ee032b363d0b7d98e57a9ff6164d0')

prepare() {
  cd ${pkgname}-${pkgver}
  sed -e 's|"p0f.fp"|"/etc/p0f/p0f.fp"|g' -i config.h
  sed -e 's|/usr/local/|/usr/|g' -i build.sh
  sed -e "s|-g -ggdb||g" -i build.sh
  sed -e "s|-g -ggdb|${CFLAGS}|g" -i tools/Makefile
  sed -r "s|(LDFLAGS =)|\1 ${LDFLAGS}|g" -i tools/Makefile
}

build() {
  cd ${pkgname}-${pkgver}
  make
  cd tools
  make p0f-client
  make p0f-sendsyn
  make p0f-sendsyn6
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 755 p0f "${pkgdir}/usr/bin/p0f"
  install -Dm 644 p0f.fp "${pkgdir}/etc/p0f/p0f.fp"
  install -Dm 644 docs/COPYING "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -Dm 644 docs/README "${pkgdir}/usr/share/doc/${pkgname}/README"
  install -m 755 tools/{p0f-client,p0f-sendsyn,p0f-sendsyn6} "${pkgdir}/usr/bin"
}

# vim: ts=2 sw=2 et:
